#delimit;
use 20161021_Working_hh_1014.dta, clear;

 
keep if FIPS==6 | FIPS==12 | FIPS==48;

by FIPS,sort: egen group=rank(Y), unique;
by FIPS, sort: egen count=count(Y);
replace count=count/100;
replace group=round(group/count);

collapse totalTransfer Y count (p25) p25TT=total (p75)p75TT=total, by(FIPS group); 


twoway scatter total Y if FIPS==6 & Y<=50, m(Oh) msize(small) 
	|| rspike p75TT p25TT Y if FIPS==6 & Y<=50
    || function 19.790-x, lcolor(gs2) lpattern(dash) range(0 19.790)
	|| function y=1.106+6.684*exp(-.0274*x) , range(0 50) lcolor("gs2")  lwidth(thick)
	legend(off)
	ylabel(0(5)20)
	xlabel(0(10)50)
	ytitle("Social Transfers")
	xtitle("Market Income")
	text(20 38 "California", size(large));
;

graph save 20161021_CA.gph, replace;

twoway scatter total Y if FIPS==12 & Y<=50, m(Oh) msize(small) 
	|| rspike p75TT p25TT Y if FIPS==12 & Y<=50
	|| function 19.790-x, lcolor(gs2) lpattern(dash) range(0 19.790)
	|| function y=.574+4.764*exp(-.0271*x) , range(0 50)
	lcolor("gs2")  lwidth(thick)
	legend(off)
	ylabel(0(5)20)
	xlabel(0(10)50)
	ytitle("Social Transfers")
	xtitle("Market Income")
	text(20 42 "Florida", size(large));
;

graph save 20161021_FL.gph, replace;


twoway scatter total Y if FIPS==48 & Y<=50, m(Oh) msize(small)
	|| rspike p75TT p25TT Y if FIPS==48 & Y<=50
	|| function 19.790-x, lcolor(gs2) lpattern(dash) range(0 19.790)
	|| function y=.545+4.873*exp(-.02040*x) , range(0 50)  lwidth(thick)
	lcolor("gs2")
	legend(off)
	ylabel(0(5)20)
	xlabel(0(10)50)
	ytitle("Social Transfers")
	xtitle("Market Income")
	text(20 42 "Texas", size(large));

graph save 20161021_TX.gph, replace;


graph combine 20161021_CA.gph 20161021_FL.gph 20161021_TX.gph, row(1);

graph export "20161021_CA_FL_TX.pdf", replace fontface("Helvetica"); 


